package jmetal.util;

public class MathUtil {

	public static double getAvarage(double[] hvValues) {
		double sum = 0.0;
		for(int i = 0;i<hvValues.length;i++){
			sum+=hvValues[i];
		}
		return sum/hvValues.length;
	}

	public static double getStd(double[] hvValues) {
		double ave = getAvarage(hvValues);
		double sum = 0.0;
		for(int i = 0;i<hvValues.length;i++){
			sum+=Math.pow(hvValues[i]-ave, 2);
		}
		double td = sum/(double)(hvValues.length-1);
		return Math.sqrt(td);
	}

}
